﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Legend.Component.Interface;
using Microsoft.Xna.Framework;

namespace Legend.Component.PowerBall
{
    public class PowerBallDamaging : IDamaging
    {
        public enum PowerBallType
        {
            Nothing,
            Pheonix,
            Shield,
            TypeMax,
        };
        private PowerBallType powerballType = PowerBallType.Nothing;

        public override string Status
        {
            get { return powerballType.ToString(); }
        }

        public PowerBallDamaging()
        {
            DamageDisposition = DamageType.OnlyWithWeapon | DamageType.PowerBall;
        }

        public override ResolveResult ResolveDamaging(IDamaging.DamageType fromDisposition, float fromDamage, string fromStatus)
        {
            if ((fromDisposition & DamageType.Hero) != 0)
            {
                return ResolveResult.Disappear;
            }
            else if ((fromDisposition & DamageType.Weapon) != 0)
            {
                powerballType += 1;
                if (powerballType == PowerBallType.TypeMax)
                {
                    powerballType = PowerBallType.Nothing;
                }
                IRenderable render = Owner.FindComponent<IRenderable>();

                switch (powerballType)
                {
                    case PowerBallType.Nothing:
                        render.AmbientColor = new Vector3(1, 1, 1);
                        break;

                    case PowerBallType.Pheonix:
                        render.AmbientColor = new Vector3(1, 0, 0);
                        break;

                    case PowerBallType.Shield:
                        render.AmbientColor = new Vector3(0, 0.5f, 1);
                        break;
                }
            }

            return ResolveResult.Continue;
        }
    }
}
